package com.zq.it.dao.impl.admin;

import java.util.Collection;
import java.util.Date;
import java.util.List;

import org.springframework.orm.hibernate3.HibernateTemplate;

import com.zq.it.dao.admin.NetCourseDao;
import com.zq.it.dao.impl.BaseDao;
import com.zq.it.pojo.Netcourse;

public class NetCourseDaoImpl extends BaseDao<Netcourse> implements NetCourseDao {
  /*public static final Logger logger=t(NetcourseDaoImpl.class);*/
	@Override
	public void saveNetcourseEty(Netcourse netcourse){
    	getHibernateTemplate().save(netcourse);
	}
	@Override
	public void deleteNetcourseEtyListByIds(Integer[] ids){	
		HibernateTemplate ht=getHibernateTemplate();
		for(int i=0;i<ids.length;i++){
		  ht.delete(ht.load(Netcourse.class,ids[i]));	
		}
	}
	@Override
	public List<Netcourse> findNetcourseEtyList() {
		return getHibernateTemplate().find("from Netcourse");
		// TODO Auto-generated method stub	
	}

	@Override
	public List findNetcourseEtyById(Integer id) {
		return getHibernateTemplate().find("from Netcourse where academyId=?",id);
		// TODO Auto-generated method stub
	}
	@Override
	public List<Netcourse> findNetcourseListByHQL(String hql){		
		return getHibernateTemplate().find(hql);
	}
	@Override
	public List findNetcourseEtyByName(String name){
		return getHibernateTemplate().find("from Netcourse as netc where netc.academyName=?",name);
		// TODO Auto-generated method stub
	
	}
	
	@Override
	public List findCourseTypes() {
		return getHibernateTemplate().find("select distinct type from com.zq.it.pojo.Netcourse");
	}

	@Override
	public void updateNetcourseEty(Netcourse academy) {
		getHibernateTemplate().update(academy);
		// TODO Auto-generated method stub
		
	}
	
	@Override
	public List findNetCoursesByType(String type) {
		return getHibernateTemplate().find("from com.zq.it.pojo.Netcourse as nec where nec.type='" + type + "'");
	}
	 
	@Override
	public List findNetcourseEtyByDate(Date date){
		// TODO Auto-generated method stub
		return getHibernateTemplate().find("from Netcourse where createTime=?",date);
	}
	@Override
	public List findNetcourseEtyByExmp(Netcourse academy) {
		// TODO Auto-generated method stub
		return getHibernateTemplate().findByExample(academy);
	}
	@Override
	public void deleteAllEty(java.util.Collection<Netcourse> collection){
		getHibernateTemplate().deleteAll(collection);
	}
	@Override
	public void deleteNetcourseEtyByObj(Netcourse academy){
		getHibernateTemplate().delete(academy);
	}
	@Override
	public void saveNetcourseEtyList(Collection<Netcourse> collection){
		getHibernateTemplate().saveOrUpdateAll(collection);
	}
	
}
